#pragma once
#include <iostream>
using namespace std;
#include <assert.h>
#include <pthread.h>
#include <unistd.h>
#include <mutex>
#include <vector>
#include <string>

class Mutex
{
public:
    Mutex(pthread_mutex_t *lock = nullptr) : _lock(lock)
    {
    }
    void lock()
    {
        if (_lock)
        {
            pthread_mutex_lock(_lock);
        }
    }

    void unlock()
    {
        if (_lock)
        {
            pthread_mutex_unlock(_lock);
        }
    }

    ~Mutex()
    {
    }

private:
    pthread_mutex_t *_lock;
};

class loadmutex
{
public:
    loadmutex(Mutex mutex) : _mutex(mutex)
    {
        _mutex.lock();
    }

    ~loadmutex()
    {
        _mutex.unlock();
    }

private:
    Mutex _mutex;
};